package com.settlement.system.service.impl;

import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.mapper.BaseMapper;
import com.settlement.system.mapper.TblWpDeliveryUnitPriceMapper;
import com.settlement.system.model.entity.common.TblWpDeliveryUnitPrice;
import com.settlement.system.service.ITblWpDeliveryUnitPriceService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * WP-唯品发货单价 服务实现类
 *
 * @author Ximi
 * @since 2020-10-30
 */
@Slf4j
@Service
public class TblWpDeliveryUnitPriceServiceImpl extends BaseServiceImpl implements ITblWpDeliveryUnitPriceService {

    @Resource
    private TblWpDeliveryUnitPriceMapper tblWpDeliveryUnitPriceMapper;

    @Override
    public BaseMapper init() {
        return tblWpDeliveryUnitPriceMapper;
    }

    /*@Reference(version = "${dubbo.acs.api.version}", timeout = 6000)
    private WpUnitPriceApi wpUnitPriceApi;*/

    @Override
    public TblWpDeliveryUnitPrice getFoot(Map<String, Object> params) throws ServiceException {
        try {
            return tblWpDeliveryUnitPriceMapper.getFoot(params);
        } catch (Exception ex) {
            log.error("获取合计异常", ex);
            throw new ServiceException("获取合计异常", ex);
        }
    }

    /**
     * 删除数据 通过批次编号
     *
     * @param minBatchNumber
     * @param maxBatchNumber
     */
    @Override
    public void deleteByBatchNumbers(String minBatchNumber, String maxBatchNumber) {
        tblWpDeliveryUnitPriceMapper.deleteByBatchNumbers(minBatchNumber, maxBatchNumber);
    }

    /**
     * 修改批量保存的逻辑
     *
     * @param list
     * @param <ModelType>
     * @throws ServiceException
     */
    @Override
    public <ModelType> void save(List<ModelType> list) throws ServiceException {
        tblWpDeliveryUnitPriceMapper.batchAdd((List<TblWpDeliveryUnitPrice>) list);
    }

    @Override
    public <ModelType> Integer insert(ModelType modelType) throws ServiceException {
        return tblWpDeliveryUnitPriceMapper.insert(modelType);
    }

    @Override
    public void refresh() throws Exception {
        try {
            /*wpUnitPriceApi.refresh();*/
        } catch (Exception ex) {
            throw new Exception("刷新异常", ex);
        }
    }


}

